package com.bmf.module.examination.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bmf.constant.AdminResultEnum;
import com.bmf.module.examination.entity.SelectionStrategy;
import com.bmf.module.examination.service.SelectionStrategyService;
import com.bmf.module.examination.vo.SelectionStrategyCreateVo;
import com.bmf.module.examination.vo.SelectionStrategyResultVo;
import com.bmf.module.examination.vo.SelectionStrategyUpdateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

import com.bmf.core.result.R;

/**
 * (SelectionStrategy)表控制层
 *
 * @author makejava
 * @since 2022-12-01 15:20:35
 */
@RestController
@RequestMapping("selectionStrategy")
@Api(tags = {"抽题策略接口"})
public class SelectionStrategyController{
    /**
     * 服务对象
     */
    @Resource
    private SelectionStrategyService selectionStrategyService;


    /**
     * 新增数据
     *
     * @param selectionStrategyCreateVo 实体对象
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "新增抽题策略")
    public R<Integer> insert(@RequestBody SelectionStrategyCreateVo selectionStrategyCreateVo) {
        return R.success(selectionStrategyService.insert(selectionStrategyCreateVo));
    }

    /**
     * 修改数据
     *
     * @param selectionStrategyUpdateVo 实体对象
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改抽题策略")
    public R<Void> update(@RequestBody SelectionStrategyUpdateVo selectionStrategyUpdateVo) {
        selectionStrategyService.update(selectionStrategyUpdateVo);
        return R.ok();
    }

    /**
     * 删除数据
     *
     * @param ids 主键结合
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除抽题策略")
    public R<Void> delete(@RequestBody List<Long> ids) {
        selectionStrategyService.delete(ids);
        return R.ok();
    }

    /**
     * 查找数据
     *
     * @param ids 主键结合
     * @return 删除结果
     */
    @PostMapping("/select")
    @ApiOperation(value = "根据大题id查找抽题策略")
    public R<Map<String,List<SelectionStrategyResultVo>>> select(@RequestBody List<Integer> ids) {
        return R.success(selectionStrategyService.select(ids));
    }


    @PostMapping("/updateScoreByBigQuestionId/{id}/{score}")
    @ApiOperation(value = "根据大题id修改分数")
    public R<Void> updateScoreByBigQuestionId(@PathVariable("id") Integer id, @PathVariable("score") Double score) {
        selectionStrategyService.updateScoreByBigQuestionId(id,score);
        return R.ok();
    }


}

